<?php
/**
 * 登陆u
 */
namespace app\index\controller;

use think\Db;
use think\Request;
use think\Session;
class LoginController extends  BaseController{
	//登陆
	public function index(){
		$request=request::instance();
		$params=$request->only('uname,upssword');
		//var_dump($params);die;
		if($res=Db::name('authen')->where('name' ,'eq',$params['uname'] )->where('password','eq',md5($params['upssword'] ) )->find() ){
			Session::set('uid',$res['id']);
			Session::set('uname',$res['name']);
			echo "<script>alert('登陆成功');window.location.href='/index/index/index';</script>";
		}else{
			echo "<script>alert('账号或密码有误，请重新登陆!');window.location.href='/index/answer/index';</script>";
		}
	}
	//销毁所有session
	public function logsession(){
		Session::clear();
        $this->redirect('index/index/index');
	}
}